using System;
using log4net;
using seanfoy.oopsnet;

namespace seanfoy.oopsnet {
    public class L4NHandler : ASPNetErrorHandler {
        override public Exception Preprocess(Exception e) {
            Exception result = base.Preprocess(e);
            String loggername = ASPNetErrorHandler.AppSettings["seanfoy.oopsnet.l4n.logger-name"];
            if (loggername != null) {
                if (!log4net.LogManager.GetLoggerRepository().Configured) {
                    log4net.Config.XmlConfigurator.Configure();
                }
                log4net.ILog log = log4net.LogManager.GetLogger(loggername);
                log.Error(ASPNetErrorHandler.stringify(result));
            }
            return result;
        }
    }
}
